"""积分显示器"""

from component.label import Label


class ScoreView(object):
    def __init__(self,screen):
        self.label = Label("0","#000000","",22)
        self.score = 0
        self.screen = screen
        self.screen_rect = screen.get_rect()        
        self.set_score(self.score)

    def set_score(self,addScore):
        self.score += addScore
        self.label.render("当前积分:"+str(self.score))        
        self.set_pos() #特别注意 坐标的设置必须在draw之前 因为draw之后才能看到坐标的变化
    
    def is_level(self):
        return self.score%10==0
        
    def draw(self):
        self.label.draw(self.screen) 

    def set_pos(self):
        self.label.rect.right = self.screen_rect.right-10 
        self.label.rect.top =  20